<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:sd="http://www.w3.org/ns/sparql-service-description#">
<head>
    <title resource="?this">{rdfs:label}</title>
    <link rel="help" href="../../callimachus-for-web-developers#Datasource" target="_blank" title="Help" />
    <script type="text/javascript">
        $(function(){
            var sd = "http://www.w3.org/ns/sparql-service-description#";
            var label = 'label[rel="sd:supportedLanguage"]';
            $(label + '[resource="' + sd + 'SPARQL11Query"]').each(function(){
                if ($(this).find('input:checked').length) {
                    var other = $(this).siblings('label[resource="' + sd + 'SPARQL11Query"]');
                    $(this).children('span').text(other.children('span').text());
                    other.remove();
                }
            });
            $(label + '[resource="' + sd + 'SPARQL11Update"]').each(function(){
                if ($(this).find('input:checked').length) {
                    var other = $(this).siblings('label[resource="' + sd + 'SPARQL11Update"]');
                    $(this).children('span').text(other.children('span').text());
                    other.remove();
                }
            });
            $('label[class="checkbox"]').change(function(){
                if ($(this).children('input:checked').length) {
                    $(this).attr("rel", "sd:supportedLanguage");
                } else {
                    $(this).removeAttr("rel");
                }
            });
        });
    </script>
</head>
<body resource="?this">
    <h1 property="rdfs:label" />
    <form role="form" method="POST" action="" enctype="application/sparql-update" resource="?this">
        <fieldset>
            <div class="form-group">
                <label for="label">Label</label>
                <div class="controls">
                    <input type="text" class="form-control" id="label" value="{rdfs:label}" required="required" />
                </div>
            </div>
            <div class="form-group">
                <label for="comment">Comment</label>
                <div class="controls">
                    <textarea id="comment" class="form-control">{rdfs:comment}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label for="support">Support</label>
        		<div id="support" class="controls">
                	<label class="checkbox" resource="http://www.w3.org/ns/sparql-service-description#SPARQL11Query">
        				<input type="checkbox" name="support" />
        				<span>SPARQL Query</span>
        			</label>
                	<label class="checkbox" rel="sd:supportedLanguage" resource="?support">
        				<input type="checkbox" name="support" checked="checked" />
        				<span>{?support}</span>
        			</label>
            		<label class="checkbox" resource="http://www.w3.org/ns/sparql-service-description#SPARQL11Update">
        				<input type="checkbox" name="support" />
        				<span>SPARQL Update</span>
        			</label>
        		</div>
            </div>
            <div class="form-group">
                <button id="save-datasource" type="submit" class="btn btn-primary">Save</button>
                <button id="cancel-datasource" type="button" class="btn btn-default"
                    onclick="window.location.replace('?view')">Cancel</button>
                <button id="delete-datasource" type="button" class="btn btn-danger"
                    onclick="calli.deleteResource(event)">Delete</button>
            </div>
        </fieldset>
    </form>
</body>
</html>
